﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Validation;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KeyCore.Framework.DbInit;

namespace ConsoleApplication1Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Database.SetInitializer(new DbSeedingInit());
            using (var ctx = new KeyCoreDbModel())
            {
                try
                {
                    ctx.Database.Initialize(true);
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Class: {0}, Property: {1}, Error: {2}",
                                validationErrors.Entry.Entity.GetType().FullName,
                                validationError.PropertyName,
                                validationError.ErrorMessage);
                        }
                    }
                    throw;
                }
            }
        }
    }
}
